package com.example.mapper;

import com.example.pojo.Report;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ReportMapper {
    // 获取Report列表
    @Select("<script>" +
            "SELECT * FROM report " +
            "<where>" +
            "   <if test='status != null'>AND status = #{status}</if>" +
            "</where>" +
            "</script>")
    List<Report> list(String status);

    // 根据id查看某条Report
    @Select("SELECT * FROM report WHERE id = #{id}")
    Report findById(Integer id);

    // 更新举报状态为已处理
    @Update("UPDATE report SET status = 'resolved', updated_at = NOW() WHERE id = #{reportId}")
    void updateToResolved(Integer reportId);

    // 更新举报状态为已驳回
    @Update("UPDATE report SET status = 'rejected', updated_at = NOW() WHERE id = #{reportId}")
    void updateToRejected(Integer reportId);
}